﻿#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QBrush>
#include <QDesktopWidget>
#include <QProcess>
#include <QTcpSocket>
#include "modifystation.h"
#include "mainwindow.h"
#include "../include/settings.h"
#include "../include/global.h"
#include "dataWidget.h"
#include "./datasource.h"
#include "./uartconfig.h"
#include "./netconfig.h"
#include "./sqlconfig.h"
#include "./include/hled.h"
#include "./include/hleds.h"
#include "src/utility/utility.h"
#include "../include/taskthread.h"
#include "datafactory.h"
#include "gomessage.h"
#include "./wave/displayWidgetExample.h"
#include "reportchart.h"
#include "admin.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
	ui.setupUi(this);
	initObject();
	setWindowTitle(QString::fromWCharArray(L"地铁实时远程动态监控软件系统"));
	this->setCentralWidget(mainWidget);
	setWindowState(Qt::WindowMaximized);
#if 0
	QDesktopWidget* desktop = QApplication::desktop();
	resize(desktop->width() * 7 / 8, desktop->height() * 7 / 8);
	move((desktop->width() - this->width()) / 2, (desktop->height() - this->height()) / 2 - 20);
#endif

	//background
	this->setAutoFillBackground(true);
	QPalette palette;
	palette.setColor(QPalette::Background, QColor(35, 202, 255));
	//palette.setColor(QPalette::Background, Qt::white);
	this->setPalette(palette);

	QHBoxLayout *hBoxLayout = new QHBoxLayout(mainWidget);
	QVBoxLayout *vHboxLayoout = new QVBoxLayout(mainWidget);
	vHboxLayoout->addWidget(mainTableWidget, 1);
	vHboxLayoout->addWidget(dataWidget, 3);
	hBoxLayout->addLayout(vHboxLayoout, 8);
	hBoxLayout->addWidget(mainTreeWidget, 1);
	mainWidget->setLayout(hBoxLayout);
	statusBar()->setStyleSheet(QString("QStatusBar::item{border:0px}"));

	led[SOFT_SYSTEM_LED]->setHaveText(true);
	led[SOFT_SYSTEM_LED]->setText(QString(QString::fromWCharArray(L"软件系统")));
	led[SOFT_SYSTEM_LED]->turnOn();
	statusBar()->addWidget(led[SOFT_SYSTEM_LED], 1);
	led[MYSQL_LED]->setHaveText(true);
	led[MYSQL_LED]->setText(QString(QString::fromWCharArray(L"MySQL数据库")));
	led[MYSQL_LED]->turnOff();
	statusBar()->addWidget(led[MYSQL_LED], 1);
	led[TCPSERVER_LED]->setHaveText(true);
	led[TCPSERVER_LED]->setText(QString(QString::fromWCharArray(L"远程服务器")));
	led[TCPSERVER_LED]->turnOff();
	statusBar()->addWidget(led[TCPSERVER_LED], 1);
	led[UART_LED]->setHaveText(true);
	led[UART_LED]->setText(QString(QString::fromWCharArray(L"串口")));
	led[UART_LED]->turnOff();
	statusBar()->addWidget(led[UART_LED], 2);
	// dateLabel->setText(QDateTime::currentDateTime().toString("yyyy--MM--dd"));
	// statusBar()->addWidget(dateLabel,1);
	statusBar()->addWidget(leds, 1);
	//产生数据
	dataFactory->start();
}
void MainWindow::initObject()
{
	mainWidget = new QWidget(this);
	mainTableWidget = new TableWidget(mainWidget);
	mainTreeWidget = new TreeWidget(mainWidget);
	dataWidget = new DataWidget(this);
	dataFactory = new DataFactory(this);

	for(int i = 0 ; i < N_LEDS; ++i)
		led[i] = new HLed(this);

	leds = new HLeds(this);
	dateLabel = new QLabel(this);
	initTableWidget();
	initTreeWidget();
	stationLeafNums = 0;
	initTreeWidgetData();
	buildWithFactoryRelations();
	//sqlUpdateLed(true);
	currentRow =0;


}

void MainWindow::buildWithFactoryRelations()
{
	//time bus
	connect(&(dataFactory->getTimeBus()), SIGNAL(sendTime(long)), this, SLOT(checkSomethingsAndUpdateUI(long)));
	//serial close.  serial open failure status change isnot there.
	connect(dataFactory->getSerialPort(), SIGNAL(aboutToClose()), this, SLOT(uartStatesUpdate())) ;
	//mysql.open failure or success status change isnot there.
	connect(dataFactory->getSqlThread(), SIGNAL(openError(const QString&)), this, SLOT(sqlStatesUpdate(const QString&))) ;
	connect(dataFactory->getSqlThread(), SIGNAL(openSqlSuccess()), this, SLOT(sqlLedOpen())) ;
	//net
	connect(dataFactory->getTcpSocket(), SIGNAL(connected()), this, SLOT(socketConnected()));
	connect(dataFactory->getTcpSocket() , SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
	connect(dataFactory->getTcpSocket(), SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(haveError()));
	//datafactory(when serial or net data is comint,the signal will be emited)
	connect(dataFactory, SIGNAL(sendRemoteDataToMaiwindow(int, int, int, float)),
		this, SLOT(updateDataWidgetWaveUI(int, int, int, float)));
}



//更新串口状态
void MainWindow::uartStatesUpdate(bool flag)
{
    if(!flag)
    {
        dataFactory->setUARTState(UART_CLOSED);
        led[UART_LED]->turnOff();
    }
    else
    {
        dataFactory->setUARTState(UART_OPEN);
        led[UART_LED]->turnOn();
    }
}
//更新SQL状态
void MainWindow::sqlUpdateLed(bool flag)
{
	if(!flag)
	{
		dataFactory->setSQLState(SQL_DISCONNECTED);
		led[MYSQL_LED]->turnOff();
	}
	else
	{
		dataFactory->setSQLState(SQL_CONNECTED);
		led[MYSQL_LED]->turnOn();
	}
}
void MainWindow::checkSomethingsAndUpdateUI(long t)
{
	leds->updateLedsUI();
	dataWidget->updateDatawidgetUI(t);
	dataFactory->checkNetWhenUseNet();
	//when t ==0, update mysql table
}

void MainWindow::sqlStatesUpdate(const QString& tx)
{
    dataFactory->setSQLState(SQL_DISCONNECTED);
    led[MYSQL_LED]->turnOff();
    goMessage* note = new goMessage(QString::fromWCharArray(L"警告:数据库出错！"), 3000, this);
    note->show();
}

void MainWindow::socketConnected()
{
    dataFactory->setNetState(NET_CONNECTED);
    led[TCPSERVER_LED]->turnOn();
    goMessage* note = new goMessage(QString::fromWCharArray(L"成功：连接到服务器！"), 3000, this);
    note->show();
}
void MainWindow::socketDisconnected()
{
    dataFactory->setNetState(NET_DISCONNECTED);
    led[TCPSERVER_LED]->turnOff();
    goMessage* note = new goMessage(QString::fromWCharArray(L"提醒：与服务器断开连接！"), 3000, this);
    note->show();
}
void MainWindow::haveError()
{
    dataFactory->setNetState(NET_DISCONNECTED);
    led[TCPSERVER_LED]->turnOff();
    goMessage* note = new goMessage(QString::fromWCharArray(L"出错：通信不成功！"), 3000, this);
    note->show();
}

void MainWindow::updateDataWidgetWaveUI(int stationNo, int sensorType, int sensorNo,float data)
{
   // qDebug() << QString::fromWCharArray(L"通知页面") <<stationNo<<"  "<< sensorNo <<"  "<<data<< endl;
    //1.update tables data
    /*!
      add some codes
    */
    //2.update datawidget wave
	//2015-05-27
    
	//更新table
	 QTableWidgetItem *item = mainTableWidget->item(stationNo, sensorNo+2);
#if 1
	 if(data>=-5 && data <= 5){
		 item->setText( QString::fromWCharArray(L"故障"));
	 }else{
#endif 
		 //float f = (float)data/10000.0;
		 dataWidget->updateDatawidgetWave(stationNo, sensorType, sensorNo, data);
		 if(sensorNo>=13){return;}
		 item->setText(QString("%1").arg(data));
		 
	 }
	 dataFactory->getTimeBus().setFistCheckSim(false);//检测
}



/*==================================================================
 *    功能：   该函数用于接收TreeWidget的Item双击信号
 *    输入参数：
 *    返回值：
/*==================================================================*/
void MainWindow::acceptFromTreeWidget(QTreeWidgetItem * item, int column)
{
# if 1

    switch(item->type())
    {
        case TreeWidget::STATION:
            {
                //获取station的编号，因为不同的Station有不同的编号
                QString id = item->text(0);
                int index = id.remove(0, id.lastIndexOf("#") + 1).toInt();
                ModifyStation *modifyStation = new ModifyStation(index, this);//-1
                modifyStation->changleTitle(QString(QString::fromWCharArray(L"更新采集站信息")));
                //采集站修改后点击OK
                connect(modifyStation, SIGNAL(updateStationSignal(int)), this, SLOT(updateTableItem(int)));
                modifyStation->show();
                break;
            }

        case TreeWidget::STATION_ADD:
            {
                ModifyStation *modifyStation = new ModifyStation(this);
                modifyStation->changleTitle(QString(QString::fromWCharArray(L"增加采集站")));
                //采集站增加信息填好后点击OK
                connect(modifyStation, SIGNAL(addNewStationSignal()), this, SLOT(addNewTableItem()));
                modifyStation->show();
                break;
            }

        case TreeWidget::DATA_SOURCE:
            {
                DataSource *ds = new DataSource(this);
                ds->show();
                break;
            }

        case TreeWidget::CFG_UART:
            {
                UartConfig *uart = new UartConfig(dataFactory->getSerialPort(), this);
                uart->show();
                break;
            }

        case TreeWidget::CFG_NET:
            {
                NetConfig *net = new NetConfig(dataWidget, this);
                net->show();
                break;
            }

        case TreeWidget::CFG_SQL:
            {
                SqlConfig *sql = new SqlConfig(dataFactory->getSqlThread(), this);
                sql->show();
                break;
            }

        case TreeWidget::DATA_HISTORY_WAVE:
            {
				if(dataFactory->getSQLState() != SQL_CONNECTED)
				{
					goMessage* note = new goMessage(QString::fromWCharArray(L"数据库未连接"), 1000, this);
					note->show();
					return;
				}
                DisplayWidgetExample *dw = new DisplayWidgetExample(this);
                dw->show();
                break;
            }
		case TreeWidget::DATA_QUERY:
			{
				if(dataFactory->getSQLState() != SQL_CONNECTED)
				{
					goMessage* note = new goMessage(QString::fromWCharArray(L"数据库未连接"), 1000, this);
					note->show();
					return;
				}
				ReportChart* rc = new ReportChart(this);
				rc->show();
				break;
			}
		case TreeWidget::CFG_FILE:
			{
				admin *ad = new admin( dataFactory,this);
				ad->show();
				break;
			}
    }

#endif
}

/*==================================================================
 *    功能：   在tableWidget中增加新的行
 *    输入参数：
 *    返回值：
/*==================================================================*/
void MainWindow::addNewTableItem()
{
	//Tree中增加
	initTreeWidgetData();
    initTableWidgetData();
}

/*==================================================================
 *    功能：   更新tableWidget中的某行
 *    输入参数：index为采集站编号，从1开始编号
 *    返回值：
/*==================================================================*/
void MainWindow::updateTableItem(int index)
{
    unsigned int maskg = Settings::readMask(index,DATA_G);
	unsigned int masky = Settings::readMask(index,DATA_Y);
    QTableWidgetItem *item;
    int sensors = 0;

    for(int j = 2;  j  <= SENSOR_G_NUMS + 1; ++j)
    {
        item = mainTableWidget->item(index - 1, j);

        if(maskg & 0x0001)
        {
            ++sensors;
            item->setBackground(QBrush(Qt::white));
            item->setText("------");
        }
        else
        {
            item->setBackground(QBrush(QColor(255, 192, 203)));
            item->setText("X");
        }

        maskg >>= 1;
    }
	for(int j = 6;  j  <= SENSOR_Y_NUMS + 5; ++j)
	{
		item = mainTableWidget->item(index - 1, j);

		if(masky & 0x0001)
		{
			++sensors;
			item->setBackground(QBrush(Qt::white));
			item->setText("------");
		}
		else
		{
			item->setBackground(QBrush(QColor(255, 192, 203)));
			item->setText("X");
		}

		masky >>= 1;
	}

    //插入传感器数目
    item = mainTableWidget->item(index - 1, 1);
    item->setText(QString::number(sensors, 10));
    //插入note
    item = mainTableWidget->item(index - 1, SENSOR_G_NUMS+SENSOR_Y_NUMS+2);
    item->setText(Settings::readNote(index));
}

void  MainWindow::getItem(int row, int column){
	//qDebug()<<"Row+Clu:"<<row<<"  "<<column<<endl;
	currentStation = row;
	dataWidget->setCurrentStation(row);
	goMessage* note = new goMessage(QString::fromWCharArray(L"正在加载采集站%1数据...").arg(row+1), 3000, this);
	note->show();
	if(row != currentRow){
		QTableWidgetItem *item;
		item = mainTableWidget->item(row, 0);
		item->setBackground(QBrush(Qt::red));
		item = mainTableWidget->item(currentRow, 0);
		item->setBackground(QBrush(Qt::white));
		currentRow = row;
	}

}
/*==================================================================
 *    功能：   初始化tableWidget
 *    输入参数：
 *    返回值：
/*==================================================================*/
void MainWindow::initTableWidget()
{
    mainTableWidget->setColumnCount(SENSOR_G_NUMS+SENSOR_Y_NUMS+4);  //columns
    mainTableWidget->setRowCount(0);     //rows
    mainTableWidget->horizontalHeader()->setStretchLastSection(true);
    mainTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    mainTableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
	//connect(mainTableWidget,SIGNAL(itemDoubleClicked(QTableWidgetItem*, int)),this,SLOT(getItem(QTableWidgetItem*, int)));
	connect(mainTableWidget,SIGNAL(cellDoubleClicked(int, int )),this,SLOT(getItem(int, int)));
    //mainTableWidget->verticalHeader()->setVisible(false);   //rows label
    QStringList headers;
    headers << QString(QString::fromWCharArray(L"采集站")) << QString(QString::fromWCharArray(L"传感器数目")) <<
            QString(QString::fromWCharArray(L"钢筋计1")) << QString(QString::fromWCharArray(L"钢筋计2")) << QString(QString::fromWCharArray(L"钢筋计3"))<< QString(QString::fromWCharArray(L"钢筋计4"))
            << QString(QString::fromWCharArray(L"应力计1")) << QString(QString::fromWCharArray(L"应力计2"))
			<< QString(QString::fromWCharArray(L"应力计3")) << QString(QString::fromWCharArray(L"应力计4"))
			<< QString(QString::fromWCharArray(L"应力计5")) << QString(QString::fromWCharArray(L"应力计6"))
			<< QString(QString::fromWCharArray(L"应力计7")) << QString(QString::fromWCharArray(L"应力计8"))
			<< QString(QString::fromWCharArray(L"应力计9"))
            << QString(QString::fromWCharArray(L"备注")) << QString(QString::fromWCharArray(L"预警"));
    mainTableWidget->setHorizontalHeaderLabels(headers);
    initTableWidgetData();
}

void MainWindow::tableLineSelected(){

}
/*==================================================================
 *    功能    ：   读取ini文件并初始化tableWidget
 *    输入参数：
 *    返回值    ：
 *    作者    ：
 *    日期    ：
/*==================================================================*/
void MainWindow::initTableWidgetData()
{
    QString note;
    QTableWidgetItem *item;
    int stations = Settings::readStationNum();

    for(int i =  mainTableWidget->rowCount(); i < stations; ++i)
    {
        mainTableWidget->insertRow(i); //insert a row
        item = new QTableWidgetItem(QString(QString::fromWCharArray(L"采集站 #")) + QString::number(i + 1, 10));
        item->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
        item->setBackground(QBrush(Qt::white));
		//connect(mainTableWidget, SIGNAL(), this, SLOT(socketConnected()));

        mainTableWidget->setItem(i, 0, item);
        unsigned int maskg = Settings::readMask(i + 1,DATA_G);
		

        int sensors = 0;
        for(int j = 2;  j  <= SENSOR_G_NUMS + 1; ++j)
        {
            item = new QTableWidgetItem("------");
            //item = new QTableWidgetItem(QString::number(i , 10)+" A "+QString::number(j, 10));
            item->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

            if(maskg & 0x0001)
            {
                ++sensors;      //sensors num
                item->setBackground(QBrush(Qt::white));
            }
            else
            {
                item->setBackground(QBrush(QColor(255, 192, 203)));
                item->setText("X");
            }

            mainTableWidget->setItem(i, j, item);
            maskg >>= 1;
        }
		unsigned int masky = Settings::readMask(i + 1,DATA_Y);
		for(int j = 6;  j  <= SENSOR_Y_NUMS + 5; ++j)
		{
			item = new QTableWidgetItem("------");
			//item = new QTableWidgetItem(QString::number(i , 10)+" A "+QString::number(j, 10));
			item->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

			if(masky & 0x0001)
			{
				++sensors;      //sensors num
				item->setBackground(QBrush(Qt::white));
			}
			else
			{
				item->setBackground(QBrush(QColor(255, 192, 203)));
				item->setText("X");
			}

			mainTableWidget->setItem(i, j, item);
			masky >>= 1;
		}

        //插入传感器数目
        item = new QTableWidgetItem(QString::number(sensors, 10));
        item->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
        item->setBackground(QBrush(Qt::white));
        mainTableWidget->setItem(i, 1, item);
        //插入note
        note = Settings::readNote(i + 1);
        item = new QTableWidgetItem(note);
        item->setBackground(QBrush(Qt::white));
        item->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
        mainTableWidget->setItem(i, SENSOR_G_NUMS+SENSOR_Y_NUMS+2, item);
        //插入状态
        item = new QTableWidgetItem();
        item->setBackground(QBrush(Qt::green));
        mainTableWidget->setItem(i, SENSOR_G_NUMS+SENSOR_Y_NUMS+3, item);
    }

	stationsNums = stations;
	currentStation = 0;
	dataWidget->setCurrentStation(0);
	dataWidget->setTotalStations(stations);
	//更新波形窗口的采集站数目，和当前显示采集站数据
	if(stations >=1){
		currentRow = 0;
		QTableWidgetItem *item;
		item = mainTableWidget->item(0, 0);
		item->setBackground(QBrush(Qt::red));
	}
}

MainWindow::~MainWindow()
{
    Utility::DESTORY_PTR(mainTreeWidget);
    Utility::DESTORY_PTR(mainTableWidget);
    Utility::DESTORY_PTR(dataWidget);
    Utility::DESTORY_PTR(dataFactory);
    Utility::DESTORY_PTR(leds);
    Utility::DESTORY_PTR(dateLabel);

    for(int i = 0 ; i < N_LEDS; ++i)
        Utility::DESTORY_PTR(led[i]);
}
void MainWindow::initTreeWidgetData()
{
	int stations = Settings::readStationNum();
	//qDebug()<<"采集站"<<stations<<"  "<<stationLeafNums<<endl;
	for (int i = stationLeafNums; i < stations; ++i)
	{
		stationLeafNums++;
		mainTreeWidget->addTreeLeaf(itemCollectionStation, QString(QString::fromWCharArray(L"采集站 #") + QString::number(i + 1, 10)), TreeWidget::STATION);

	}
}

void MainWindow::initTreeWidget()
{
    /*QTreeWidgetItem * */itemCollectionStation = new QTreeWidgetItem(QStringList(QString(QString::fromWCharArray(L"采集站"))));
    itemCollectionStation->setIcon(0, QIcon(":/new/prefix1/img/01.png"));
	initTreeWidgetData();
    //mainTreeWidget->addTreeLeaf(itemCollectionStation, QString(QString::fromWCharArray(L"采集站 #1")), TreeWidget::STATION);
   // mainTreeWidget->addTreeLeaf(itemCollectionStation, QString(QString::fromWCharArray(L"采集站 #2")), TreeWidget::STATION);
   // mainTreeWidget->addTreeLeaf(itemCollectionStation, QString(QString::fromWCharArray(L"采集站 #3")), TreeWidget::STATION);
    mainTreeWidget->addTreeLeaf(itemCollectionStation, QString(QString::fromWCharArray(L"新建")), TreeWidget::STATION_ADD);
	
    mainTreeWidget->addTopLevelItem(itemCollectionStation);

    itemCollectionStation->setExpanded(true);
    QTreeWidgetItem *itemDataDisplay = new QTreeWidgetItem(QStringList(QString(QString::fromWCharArray(L"数据显示"))));
    itemDataDisplay->setIcon(0, QIcon(":/new/prefix1/img/02.png"));
    mainTreeWidget->addTreeLeaf(itemDataDisplay, QString(QString::fromWCharArray(L"动态波形")), TreeWidget::DATA_DYNAMIC_DISPLAY);
    mainTreeWidget->addTreeLeaf(itemDataDisplay, QString::fromWCharArray(L"历史波形"), TreeWidget::DATA_HISTORY_WAVE);
    mainTreeWidget->addTreeLeaf(itemDataDisplay, QString::fromWCharArray(L"历史数据查询"), TreeWidget::DATA_QUERY);
    //mainTreeWidget->addTreeLeaf(itemDataDisplay, QString(QString::fromWCharArray(L"样例波形")), TreeWidget::DATA_SAMPLE_WAVE);
    mainTreeWidget->addTopLevelItem(itemDataDisplay);
    itemDataDisplay->setExpanded(true);
    QTreeWidgetItem *itemConfig = new QTreeWidgetItem(QStringList(QString::fromWCharArray(L"系统配置")));
    itemConfig->setIcon(0, QIcon(":/new/prefix1/img/03.png"));
    mainTreeWidget->addTreeLeaf(itemConfig, QString::fromWCharArray(L"数据源"), TreeWidget::DATA_SOURCE);
    mainTreeWidget->addTreeLeaf(itemConfig, QString::fromWCharArray(L"串口"), TreeWidget::CFG_UART);
    mainTreeWidget->addTreeLeaf(itemConfig, QString::fromWCharArray(L"网络"), TreeWidget::CFG_NET);
    mainTreeWidget->addTreeLeaf(itemConfig, QString::fromWCharArray(L"数据库"), TreeWidget::CFG_SQL);
    mainTreeWidget->addTreeLeaf(itemConfig, QString::fromWCharArray(L"配置文件"), TreeWidget::CFG_FILE);
    mainTreeWidget->addTreeLeaf(itemConfig, QString::fromWCharArray(L"预警值"), TreeWidget::CFG_LEVEL);
    mainTreeWidget->addTopLevelItem(itemConfig);
    itemConfig->setExpanded(true);
    QTreeWidgetItem *itemAlgorithm = new QTreeWidgetItem(QStringList(QString::fromWCharArray(L"数据处理")));
    itemAlgorithm->setIcon(0, QIcon(":/new/prefix1/img/04.png"));
    mainTreeWidget->addTreeLeaf(itemAlgorithm, QString::fromWCharArray(L"数据模型"), TreeWidget::ALGORITHM1);
    mainTreeWidget->addTreeLeaf(itemAlgorithm, QString::fromWCharArray(L"算法"), TreeWidget::ALGORITHM1);
    mainTreeWidget->addTopLevelItem(itemAlgorithm);
    itemAlgorithm->setExpanded(true);
    QTreeWidgetItem *help = new QTreeWidgetItem(QStringList(QString::fromWCharArray(L"帮助&关于")));
    help->setIcon(0, QIcon(":/new/prefix1/img/help.png"));
    mainTreeWidget->addTreeLeaf(help, QString::fromWCharArray(L"关于"), TreeWidget::ABOUT);
    mainTreeWidget->addTreeLeaf(help, QString::fromWCharArray(L"帮助"), TreeWidget::HELP);
    mainTreeWidget->addTopLevelItem(help);
    help->setExpanded(true);
    connect(mainTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(acceptFromTreeWidget(QTreeWidgetItem*, int)));
}

